package com.apes.pi.service;

import com.apes.framework.api.DomainService;
import com.apes.framework.plugin.esb.api.SimpleRequest;
import com.apes.framework.plugin.event.Listener;
import com.apes.framework.plugin.mq.MQUtil;
import com.apes.framework.plugin.mq.annotation.Consumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("mqChannelService")
public class MqChannelService extends DomainService {

    @Autowired
    private PiManager piManager;

    /***
     * 推送消息
     */
    public void publish(SimpleRequest request){
        MQUtil.publish("yyerp.mqChannel.consume", "老框架事务发件箱", request.getData());
    }

    /***
     * 老框架事务发件箱消费
     */
    @Consumer(topic="yyerp.mqChannel.consume")
    public void consume(SimpleRequest request) {
        piManager.synErp("mqConsumerService.consume", request.getJO());
    }
}
